package lexicalUnit;

import chalmersbot.Absyn.QWHowMany;
import chalmersbot.Absyn.QWHow.Visitor;

public class CheckQWHow implements Visitor<String, Environ> {

	@Override
	public String visit(QWHowMany p, Environ env) {
		if (!(env.getTarget()==-1)){
			env.setKeywordClass(env.getTarget());
		}
		env.setTarget(Environ.COUNT);
		String answer = env.generateAnswer();
		double value = Double.parseDouble(answer);
		if (value>1)
			return "there are " + answer + " " + env.getSubject();
		String sing = env.toSingular(env.getSubject());
		if (value == 0)
			return "there are no " + env.getSubject();
		return "there is 1 " + sing;
	}

}
